package thread;

import com.sun.xml.internal.stream.util.ThreadLocalBufferAllocator;

/**
 * 使用匿名内部类形式来实现线程(两种方式)
 */
public class ThreadDemo3 {
    public static void main(String[] args) {
        Thread t1 = new Thread(){
            @Override
            public void run() {
                for (int i=0;i<100;i++){
                    System.out.println("你是谁呀?");
                }
            }
        };
        t1.start();

        Runnable r = new Runnable() {
            @Override
            public void run() {
                for (int i=0;i<100;i++){
                    System.out.println("我是芭芭拉!");
                }
            }
        };

        Thread thread = new Thread(r);
        thread.start();

        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i=0;i<100;i++){
                    System.out.println("我是芭芭拉!");
                }
            }
        });
        t2.start();


        Thread t3 = new Thread(() ->{
            for (int i=0;i<100;i++){
                System.out.println("我是芭芭拉!");
            }
        });
        t3.start();


    }
}

